package goodenglish.interfaces;

import goodenglish.infrastructure.FileUtil;

import java.io.File;
import java.io.IOException;

import javafx.scene.web.WebView;

public class WebVieweHelper {

	public static void setHtmlText( WebView browser,String text) {
		try {
			File file = File.createTempFile("sentence", ".html");
			StringBuffer buffer = new StringBuffer();
			buffer.append("<html><head>");
			buffer.append("<meta http-equiv='Content-Type' content='text/html; charset=gb2312'/>");
			buffer.append("</head><body>");
			buffer.append(text);
			buffer.append("</body></html>");
			FileUtil.WriteStrToFile(file, buffer.toString());
			browser.getEngine().load("file:///" + file.getPath());
			file.deleteOnExit();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
